<template>
  <el-aside width="200px">
    <el-menu
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b"
      default-active="2"
      :default-openeds="opendeds"
    >
      <div class="toggle">
        <el-switch
          v-model="value"
          active-color="#13ce66"
          inactive-color="#ff4949"
        >
        </el-switch>
      </div>
      <el-submenu
        :index="item.id + ''"
        v-for="item in asideMenu"
        :key="item.id"
      >
        <template slot="title">
          <i :class="iconList[item.id]"></i>
          <span>{{ item.authName }}</span>
        </template>
        <el-menu-item-group v-for="list in item.children" :key="list.id">
          <el-menu-item :index="list.id + ''">{{ list.authName }}</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
    </el-menu>
  </el-aside>
</template>

<script>
export default {
  props: {
    asideMenu: {
      type: Array,
    },
  },
  data() {
    return {
      iconList: {
        125: "el-icon-user-solid",
        103: "el-icon-picture-outline-round",
        101: "el-icon-s-management",
        102: "el-icon-s-claim",
        145: "el-icon-s-data",
      },
    };
  },
  computed: {
    opendeds() {
      let arr = [];
      for (const data of this.asideMenu) {
        arr.push(data.id + "");
      }
      return arr;
    },
  },
};
</script>

<style lang="scss" scoped>
.el-aside {
  background-color: rgb(238, 241, 246);
  .el-menu {
    border-right-width: 0px;
  }
}
</style>